package com.deyuanyun.pic.settings.service.prvlg.impl;

import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.settings.controller.dto.prvlg.UserGroupGrant;
import com.deyuanyun.pic.settings.controller.dto.prvlg.UserGroupQuery;
import com.deyuanyun.pic.settings.domain.prvlg.UserGroup;
import com.deyuanyun.pic.settings.mapper.prvlg.UserGroupMapper;
import com.deyuanyun.pic.settings.service.prvlg.UserGroupMgrService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 权限模块 “角色组”服务接口实现类
 *
 * 方法详情：<br/>
 *
 * @author huanglw
 * @date  2016-11-28
 *
 * History: [修改人][时间][修改描述]
 */
@Service
public class UserGroupMgrServiceImpl implements UserGroupMgrService {

	private UserGroupMapper userGroupMapper;

	@Override
	public Page<UserGroup> query(UserGroupQuery userGroupQuery) {
		return null;
	}

	@Override
	public UserGroup find(String id) {
		return userGroupMapper.selectByPrimaryKey(id);
	}

	@Override
	public int edit(UserGroup userGroup) {

		if (StringUtils.isNotNullEmpty(userGroup.getId())){
			return userGroupMapper.updateByPrimaryKeySelective(userGroup);
		}

		return userGroupMapper.insertSelective(userGroup);
	}

	@Override
	public int delete(String id) {
		UserGroup userGroup = this.find(id);
		if (userGroup != null){
			userGroup.setDeleted(Short.valueOf("1"));
			return this.edit(userGroup);
		}
		return 0;
	}

	@Override
	public int grant(UserGroupGrant userGroupGrant) {
		return 0;
	}
}
